@@ -1,9 +1,33 @@ |
||
| 1 | 1 |
class HomeController < ApplicationController |
| 2 | 2 |
skip_before_filter :authenticate_user! |
| 3 | 3 |
|
| 4 |
+ before_filter :upgrade_warning, only: :index |
|
| 5 |
+ |
|
| 4 | 6 |
def index |
| 5 | 7 |
end |
| 6 | 8 |
|
| 7 | 9 |
def about |
| 8 | 10 |
end |
| 11 |
+ |
|
| 12 |
+ private |
|
| 13 |
+ def upgrade_warning |
|
| 14 |
+ return unless current_user |
|
| 15 |
+ twitter_oauth_check |
|
| 16 |
+ basecamp_auth_check |
|
| 17 |
+ end |
|
| 18 |
+ |
|
| 19 |
+ def twitter_oauth_check |
|
| 20 |
+ if ENV['TWITTER_OAUTH_KEY'].blank? || ENV['TWITTER_OAUTH_SECRET'].blank? |
|
| 21 |
+ if @twitter_agent = current_user.agents.where("type like 'Agents::Twitter%'").first
|
|
| 22 |
+ @twitter_oauth_key = @twitter_agent.options['consumer_key'].presence || @twitter_agent.credential('twitter_consumer_key')
|
|
| 23 |
+ @twitter_oauth_secret = @twitter_agent.options['consumer_secret'].presence || @twitter_agent.credential('twitter_consumer_secret')
|
|
| 24 |
+ end |
|
| 25 |
+ end |
|
| 26 |
+ end |
|
| 27 |
+ |
|
| 28 |
+ def basecamp_auth_check |
|
| 29 |
+ if ENV['THIRTY_SEVEN_SIGNALS_OAUTH_KEY'].blank? || ENV['THIRTY_SEVEN_SIGNALS_OAUTH_SECRET'].blank? |
|
| 30 |
+ @basecamp_agent = current_user.agents.where(type: 'Agents::BasecampAgent').first |
|
| 31 |
+ end |
|
| 32 |
+ end |
|
| 9 | 33 |
end |
@@ -0,0 +1,24 @@ |
||
| 1 |
+<% if @twitter_agent || @basecamp_agent %> |
|
| 2 |
+ <div class="alert alert-danger" role="alert"> |
|
| 3 |
+ <p> |
|
| 4 |
+ <b>Warning!</b> You need to update your Huginn configuration, so your agents continue to work with the new OAuth services. |
|
| 5 |
+ </p> |
|
| 6 |
+ <br/> |
|
| 7 |
+ <% if @twitter_agent %> |
|
| 8 |
+ <p> |
|
| 9 |
+ To complete the migration of your <b>Twitter</b> agents you need to update your .env file and add the following two lines: |
|
| 10 |
+ |
|
| 11 |
+ <pre> |
|
| 12 |
+TWITTER_OAUTH_KEY=<%= @twitter_oauth_key %> |
|
| 13 |
+TWITTER_OAUTH_SECRET=<%= @twitter_oauth_secret %> |
|
| 14 |
+ </pre> |
|
| 15 |
+ </p> |
|
| 16 |
+ <% end %> |
|
| 17 |
+ <% if @basecamp_agent %> |
|
| 18 |
+ <p> |
|
| 19 |
+ Your <b>Basecamp</b> agents could not be migrated automatically. You need to manually register an application with 37signals and authenticate Huginn to use it.<br/> |
|
| 20 |
+ Have a look at the <%= link_to 'Wiki', 'https://github.com/cantino/huginn/wiki/Configuring-OAuth-applications', target: '_blank' %> if you need help. |
|
| 21 |
+ </p> |
|
| 22 |
+ <% end %> |
|
| 23 |
+ </div> |
|
| 24 |
+<% end -%> |
@@ -1,4 +1,5 @@ |
||
| 1 | 1 |
<% if user_signed_in? %> |
| 2 |
+ <%= render "upgrade_warning" %> |
|
| 2 | 3 |
<%= render "signed_in_index" %> |
| 3 | 4 |
<% else %> |
| 4 | 5 |
<%= render "signed_out_index" %> |
@@ -26,6 +26,7 @@ class MigrateAgentsToServiceAuthentication < ActiveRecord::Migration |
||
| 26 | 26 |
agent.service_id = service.id |
| 27 | 27 |
agent.save!(validate: false) |
| 28 | 28 |
end |
| 29 |
+ migrated = false |
|
| 29 | 30 |
if agents.length > 0 |
| 30 | 31 |
puts <<-EOF.strip_heredoc |
| 31 | 32 |
|
@@ -36,6 +37,7 @@ class MigrateAgentsToServiceAuthentication < ActiveRecord::Migration |
||
| 36 | 37 |
|
| 37 | 38 |
|
| 38 | 39 |
EOF |
| 40 |
+ migrated = true |
|
| 39 | 41 |
end |
| 40 | 42 |
if Agent.where(type: ['Agents::BasecampAgent']).count > 0 |
| 41 | 43 |
puts <<-EOF.strip_heredoc |
@@ -45,7 +47,9 @@ class MigrateAgentsToServiceAuthentication < ActiveRecord::Migration |
||
| 45 | 47 |
|
| 46 | 48 |
|
| 47 | 49 |
EOF |
| 50 |
+ migrated = true |
|
| 48 | 51 |
end |
| 52 |
+ sleep 20 if migrated |
|
| 49 | 53 |
end |
| 50 | 54 |
|
| 51 | 55 |
def down |